#!/bin/bash
#####################################################################
# LNMP is a bash script for the installation of Nginx + PHP + MySQL.#
# Author        Hehl <1181554113@qq.com>                            #
# Blog          Http://www.cnblogs.com/ddif                         #
#####################################################################

pushd $src_dir

useradd es
echo $es_pwd | passwd es 

[ ! -d $es_version ] &&  tar zxf $es_gz
[ ! -d $es_install_dir ] && mkdir $es_install_dir
mv $es_version $es_install_dir

chown es:es $es_install_dir
chown es:es $es_install_dir/*
chown es:es $es_install_dir/$es_version/*

sed -i 's/# network.host: 192.168.0.1/network.host: 0.0.0.0/g' ${es_install_dir}/${es_version}/config/elasticsearch.yml

#Install ElasticSearch Head
su es -c "${es_install_dir}/${es_version}/bin/plugin install mobz/elasticsearch-head"

su es -c "${es_install_dir}/${es_version}/bin/elasticsearch -d"

popd